<template>
	<div class="page sleep">
		<x-header class='header' slot="header" :left-options="{backText: ''}">睡眠指导</x-header>
		<div class="top" style="height: 50px; width: 100%;"></div>
		<view-box>
			<ul class="list">
				<p v-for="item in guidance">{{item.text}}</p>
			</ul>
		</view-box>
	</div>
</template>

<script>
	import Api from '@/api/index.js' //  引入api文件
	export default {
		data(){
			return {
				customer_id: '',
				guidance: []
			}
		},
		created(){
			this.customer_id = localStorage.getItem('customer_id');
			this.getData();
		},
		methods:{
			getData(){   //  GET /improve/sleep_guidance/{customer_id}
				const sleep_guidanceApi = Api.sleep_guidanceApi + this.customer_id; //  睡眠指导
				this.$http.get(sleep_guidanceApi)
				.then(({data})=>{
					let a = data.data.guidance.replace(/\n/g, "<br/>");
					a.split('<br/>').map(e=>{
						this.guidance.push({text: e})
					})
					console.log(data)
				})
				.catch((err)=>{
					console.log(err)
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.sleep {
		position: fixed !important;
		left: 0;
		top: 0;
		right: 0;
		background: #fff;
		z-index: 999;
		width: 100%;
		height: 100%;
		overflow: hidden;
		
		.list {
			padding: 10px;
			li{
				margin-bottom: 14px;
				color: rgb(51,51,51);
				font-size: 16px;
			}
		}
	}
</style>